﻿using System;
using System.ServiceModel;

namespace ListenToAzureBlob
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Press <ENTER> to start listening.");
                Console.ReadLine();

                // Create a ServiceHost for the EchoServiceImpl type
                // and use the base address from app.config
                ServiceHost host = new ServiceHost(typeof(AzureStorageAdapterNamespace.AzureStorageAdapterService));

                // Open the ServiceHost to start listening for messages
                host.Open();

                Console.WriteLine("The service is ready.");
                Console.WriteLine("Press <ENTER> to terminate service.");
                Console.ReadLine();

                // Close the ServiceHost
                host.Close();
            }
            catch (TimeoutException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine();
            }
            catch (System.ServiceModel.CommunicationException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine();
            }

        }
    }
}
